package com.aids_malaria.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;

import com.aids_malaria.R;

import butterknife.BindView;
import butterknife.ButterKnife;


public class HeadSelectDialog extends Dialog {

    @BindView(R.id.tv_take_photo)
    TextView tv_take_photo;
    @BindView(R.id.tv_album)
    TextView tv_album;
    @BindView(R.id.tv_cancel)
    TextView tv_cancel;

    public HeadSelectDialog(@NonNull Context context,OnHeadSelectFuncClickListener onHeadSelectFuncClickListener) {
        super(context);
        setContentView(R.layout.dialog_head_select);
        ButterKnife.bind(this,this);

        this.onHeadSelectFuncClickListener = onHeadSelectFuncClickListener;

        tv_album.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (onHeadSelectFuncClickListener != null){
                    onHeadSelectFuncClickListener.fromAlbum();
                    dismiss();
                }
            }
        });

        tv_take_photo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (onHeadSelectFuncClickListener != null){
                    onHeadSelectFuncClickListener.takePhoto();
                    dismiss();
                }
            }
        });

        tv_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WindowManager.LayoutParams attributes = getWindow().getAttributes();
        attributes.width = ViewGroup.LayoutParams.MATCH_PARENT;
        attributes.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        // attributes.windowAnimations = R.style.SelectHeadDialogAnimation;
        getWindow().setAttributes(attributes);
        getWindow().setGravity(Gravity.BOTTOM);
    }

    public interface OnHeadSelectFuncClickListener{
        void takePhoto();
        void fromAlbum();
    }

    private OnHeadSelectFuncClickListener onHeadSelectFuncClickListener;

}
